package 链表;

public class _83_删除排序链表中的重复元素 {
	public ListNode deleteDuplicates(ListNode head) {
		if (head == null || head.next == null) {
			return head;
		}
		head.next = deleteDuplicates(head.next);
		if (head.val == head.next.val) {
			head = head.next;
		}
		return head;
	}

	public static ListNode deleteDuplicatesFun(ListNode head) {
		
		ListNode  curr = head;
		while (head != null && head.next != null) {
//			System.out.printf("curr"+curr+"\n");
//			System.out.printf("head"+head+"\n");
			if (head.val == head.next.val) {
				head.next = head.next.next;
			} else {
				head = head.next;
			}
		}
		return curr;
	}
	
	public static void main(String[] args) {
		ListNode no1= new ListNode(1);
		ListNode no2= new ListNode(1);
		ListNode no3= new ListNode(2);
		ListNode no4= new ListNode(3);
		ListNode no5= new ListNode(3);
		no1.next = no2;
		no2.next = no3;
		no3.next = no4;
		no4.next = no5;
		no5.next = null;
		deleteDuplicatesFun(no1);
	}
}
